<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p> {{ msg }} </p>
        <button @click="clickHandler">修改</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data() {
                return {
                    msg:"Hello World"
                }
            },
            methods: {
                clickHandler() {
                    this.msg = "demo";
                }
            },
            // 监听器
            watch: {
                // 监听msg属性的变更, value为变更的值
                'msg': function(value) {
                    console.log(value);
                }
            }
        });
    </script>
</body>
</html>